package com.zrrd.learn.chapter08;

import java.util.Scanner;

/**
 * 字符串题
 *
 * @author asus
 * @version 1.0
 * @date 2023/8/1 7:59
 */
//
//> 题目一：输入一串数字字符串，将其修改为不含连续相同数字的字符串，输出最小修改次数
//        >
//        > 例：输入111222333，可修改为151252353，最少修改3次则输出3
//
//        > 例：输入11223344，可修改为15253545，最少修改4次则输出4

public class StringWord {

    public static void q1() {
        /**
         * 计数器
         */
        int sum=0;
        Scanner scanner = new Scanner(System.in);
        java.lang.String word = scanner.next();
        StringBuilder stringBuilder = new StringBuilder(word);
       while (stringBuilder.length()>0) {
            int len = stringBuilder.length();
            java.lang.String firstLetter = stringBuilder.substring(0, 1);
            stringBuilder = new StringBuilder(stringBuilder.toString().replace(firstLetter, ""));
             sum = len - stringBuilder.length();

        }
        System.out.println("最少修改次数为：" + sum/2 );
    }


    public static void main(String[] args) {
        q1();
    }


    }


